package org.web.webdisplay.demo.config;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration("demoConfig")
public class DemoConfig {

    /**
    * 保留一个dataSource,用于springboot-mybatis加载使用，如果不涉及，运行期间永运不会使用。
    * */
    @Bean(name = "demoLocalDataSource")
    @Primary
    public DataSource dataSource() {
        HikariDataSource dataSource = new HikariDataSource();
//        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
//        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test");
//        dataSource.setUsername("root");
//        dataSource.setPassword("1234");
        return dataSource;
    }
}
